package com.caiyi.financial.nirvana.sms.controller;

import com.caiyi.financial.nirvana.sms.entity.SmsUserSign;
import com.caiyi.financial.nirvana.sms.querybean.SignQueryBean;
import com.caiyi.financial.nirvana.sms.service.SmsUserSignService;
import com.youyu.common.api.Result;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(description = "签名管理")
@RestController
@CrossOrigin
@RequestMapping("sms/sign")
public class SmsSignController extends BaseController {

    @Autowired
    private SmsUserSignService smsUserSignService;

    @ApiOperation(value = "新增签名", notes = "新增签名")
    @PostMapping("/addSign")
    public Result addSign(@RequestBody @ApiParam(name = "smsSign", value = "客户签名", required = true) SmsUserSign smsSign) {
        smsSign.setAccount(smsUser.getAccount());
        return Result.ok(smsUserSignService.addSign(smsSign));
    }

    @ApiOperation(value = "删除签名", notes = "删除签名")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "签名ID", dataType = "int", paramType = "query", required = true)})
    @PostMapping("/deleteSign")
    public Result deleteSign(Integer id) {
        return Result.ok(smsUserSignService.deleteSmsSign(id, smsUser.getAccount()));
    }

    @ApiOperation(value = "更新签名默认值", notes = "更新签名默认值")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "签名ID", required = true, dataType = "int", paramType = "query")
    })
    @PostMapping("/updateSignDefault")
    public Result updateSignDefault(Integer id) {
        return Result.ok(smsUserSignService.updateSignDefault(id, smsUser.getAccount()));
    }

    @ApiOperation(value = "查询签名", notes = "查询签名")
    @PostMapping("/getSignByParams")
    public Result getSignByParams(@RequestBody @ApiParam(name = "bean", value = "查找签名参数", required = true) SignQueryBean bean) {
        bean.setAccount(smsUser.getAccount());
        return Result.ok(smsUserSignService.getSignByParams(bean));
    }

}
